package com.study.d015propertybind.fx;

import javafx.beans.binding.IntegerBinding;
import javafx.beans.binding.NumberBinding;
import javafx.beans.property.SimpleIntegerProperty;

/**
*@description 自定义绑定 63课
*@author xtayhame
*date 2020年3月6日
*version
*since v1.0
*/
public class IntergerBindingMain {
	public static void main(String[] args) {
		SimpleIntegerProperty sp1 = new SimpleIntegerProperty(5);
		MyIntegerBinding myproperty = new MyIntegerBinding(10);
		sp1.bind(myproperty);

		System.out.println(myproperty.get());  //10
		System.out.println(sp1.get());         //10
	}

}

class MyIntegerBinding extends IntegerBinding{
	SimpleIntegerProperty sp2 = new SimpleIntegerProperty();

	public MyIntegerBinding(int x) {
		sp2.set(x);
	}

	@Override
	protected int computeValue() {
		return sp2.get();
	}


}
